package com.gzc.pm.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.skyclass.ibatis.IBatisDao;
import cn.skyclass.net.OperationResult;
import com.gzc.pm.bean.KnowledgeLibBean;

public class KnowledgeLibDao{
	
	private IBatisDao dao = new IBatisDao();
	
	public OperationResult insert(KnowledgeLibBean bean){
		return dao.executeInsert("KnowledgeLib.insert", bean);
	}
	
	public OperationResult deleteById(int id){
		return dao.executeDelete("KnowledgeLib.deleteById", id);
	}
	
	
	
	public int getCountByCondition(String title,String keyWord, String productName){
		Map<String, Object> map = new HashMap<String, Object>(3);
		map.put("title", title);
		map.put("keyWord", keyWord);
		map.put("productName", productName);
		return dao.getCount("KnowledgeLib.getCountByCondition", map);
	}
	
	@SuppressWarnings("unchecked")
	public List<KnowledgeLibBean> getInfoByCondition(String title,String keyWord, String productName,int pageNo, int pageSize){
		Map<String, Object> map = new HashMap<String, Object>(3);
		int startIndex = (pageNo-1)*pageSize;
		map.put("title", title);
		map.put("keyWord", keyWord);
		map.put("productName", productName);
		map.put("startIndex", startIndex);
		map.put("pageSize", pageSize);
		List<KnowledgeLibBean> list = dao.getList("KnowledgeLib.getInfoByCondition", map);
		return list;
	}
	
}
